using System;
using System.Collections.Generic;
using System.Text;

namespace ca.metaobjects.csogateway
{
	/// <summary>
	/// <para>
	/// Specifies various parameters affecting the creation of the cso-generated type for the class, the struct, the interface or the enum
	/// that this attribute is attached to.
	/// Attaching this attribute to a class, a struct, an interface or an enum states that it is cso-ready,
	/// i.e that a cso-generated type can be created for it.
	/// Enums are
	/// automatically cso-ready so it is not necessary to decorate an enum definition with this attribute unless some parameters needs to be specified.
	/// </para>
	/// 
	/// <table>
	///		<tr><th>Parameter name</th>			<th>Type</th>		<th>Affects</th>						<th>Effect</th></tr>
	///		<tr><td>clientSideNamespace</td>	<td>string</td>		<td>class, struct, interface enum</td>	<td>Will set the namespace of the cso-generated type. This overrides whatever is declared in the configuration.</td></tr>
	///		<tr><td>extensionUrl</td>			<td>string</td>		<td>class, struct, interface</td>		<td>The javascript file located at the specified URL will automatically be imported on the client whenever the cso-generated type is imported. This overrides whatever is declared in the configuration.</td></tr>
	///		<tr><td>ignoreBaseClass</td>		<td>bool?</td>		<td>class</td>							<td>The Type Morpher will completely ignore the base class of the current type. As if the type had System.Object as its base class.</td></tr>
	/// </table>
	/// 
	/// 
	/// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum, AllowMultiple=false, Inherited=false)]
	public class CsoGeneratedTypeAttribute : System.Attribute
    {
		private string clientSideNamespace;
		/// <summary>
		/// Gets the name of the namespace that the cso-generated type will be in.
		/// </summary>
        public string ClientSideNamespace
        {
			get { return clientSideNamespace; }
        }

		private string extensionUrl;
		/// <summary>
		/// Gets an absolute URL -or- a relative URL (relative to the root of the web server) where the file containing the javascript code extending the created cso-generated type can be found.
		/// Returns null if there is no extension file. The value returned by this property is meaningless if the attribute decorates an enum because enums cannot be extended.
		/// </summary>
		/// <value>
		///	An absolute URL like http://www.bigbank.com/AccountManager/scripts/AccountClassExtension.js
		/// -or-
		/// A URL relative to the root of the server like /AccountManager/scripts/AccountClassExtension.js
		/// </value>
		public string ExtensionUrl
		{
			get { return extensionUrl; }
		}

		private bool? ignoreBaseClass;
		/// <summary>
		/// Gets a value indicating if the Type Morpher will take into account the base class of the cso-ready class and its public properties. The value returned but this property
		/// is meaningless if the attribute decorates a struct, an enum or an interface.
		/// </summary>
		public bool? IgnoreBaseClass
		{
			get { return ignoreBaseClass; }
		}

		/// <summary>
		/// Creates a new instance of CsoGeneratedTypeAttribute specifying a namespace, an extension URL, and whether or not the Type Morpher should ignore
		/// the base class.
		/// If the attribute is attached to a struct or an interface the value of parameter ignoreBaseClass is meaningless and will be ignored by the Type Morpher.
		/// If the attribute is attached to an enum, the value parameters ignoreBaseClass and extensionURL are meaningless and will be ignored by the Type Morpher.
		/// </summary>
		/// <param name="clientSideNamespace">A name for the namespace the cso-generated type will be in. It can be one word or many words
		/// separated by periods (Ex: bigbank.entities).</param>
		/// <param name="extensionUrl">
		///	An absolute URL like http://www.bigbank.com/AccountManager/scripts/AccountClassExtension.js
		/// -or-
		/// A URL relative to the root of the server like /AccountManager/scripts/AccountClassExtension.js.
		/// Other form for the URL might be possible. The value of this parameter will end up -AS IS- in the href attribute of an HTML script tag.
		/// </param>
		/// <param name="ignoreBaseClass">true to ignore the base class of the class the attribute decorates.</param>
		public CsoGeneratedTypeAttribute(string clientSideNamespace, string extensionUrl, bool ignoreBaseClass)
		{
			this.clientSideNamespace = clientSideNamespace;
			this.extensionUrl = extensionUrl;
			this.ignoreBaseClass = ignoreBaseClass;
		}

		/// <summary>
		/// Creates a new instance of CsoGeneratedTypeAttribute specifying a namespace and an extension URL.
		/// If the attribute is attached to an enum, the value parameter extensionURL is meaningless and will be ignored by the Type Morpher.
		/// </summary>
		/// <param name="clientSideNamespace">A name for the namespace the cso-generated type will be in. It can be one word or many words separated by periods (Ex: bigbank.entities).</param>
		/// <param name="extensionUrl">
		///	An absolute URL like http://www.bigbank.com/AccountManager/scripts/AccountClassExtension.js
		/// -or-
		/// A URL relative to the root of the server like /AccountManager/scripts/AccountClassExtension.js.
		/// Other form for the URL might be possible. The value of this parameter will end up -AS IS- in the href attribute of an HTML script tag.
		/// </param>
		public CsoGeneratedTypeAttribute(string clientSideNamespace, string extensionUrl)
		{
			this.clientSideNamespace = clientSideNamespace;
			this.extensionUrl = extensionUrl;
		}

		/// <summary>
		/// Creates a new instance of CsoGeneratedTypeAttribute specifying a namespace name only.
		/// </summary>
		/// <param name="clientSideNamespace">A name for the namespace the cso-generated type will be in. It can be one word or many words separated by periods.</param>
		public CsoGeneratedTypeAttribute(string clientSideNamespace)
		{
			this.clientSideNamespace = clientSideNamespace;
		}

		/// <summary>
		/// Creates a new instance of CsoGeneratedTypeAttribute specifying only if the Type Morpher should ignore
		/// the base class.
		/// </summary>
		/// <param name="ignoreBaseClass">true to ignore the base class of the class the attribute decorates.</param>
		public CsoGeneratedTypeAttribute(bool ignoreBaseClass)
		{
			this.ignoreBaseClass = ignoreBaseClass;
		}

		/// <summary>
		/// Create a new instance of CsoGeneratedTypeAttribute specifying nothing about the cso-generated type to be created.
		/// </summary>
		public CsoGeneratedTypeAttribute()
		{
		}
    }
}
